﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" CodeBehind="List.aspx.cs" Inherits="Mani.Common.UI.List" %>

<%@ Register src="~/DynamicData/Content/GridViewPager.ascx" tagname="GridViewPager" tagprefix="asp" %>

<asp:Content ID="headContent" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">

    <h3 class="ui-widget-header">
            لیست 
            <%= table.DisplayName%>
            ها 
    </h3>

    <div class="ui-layout-content ui-widget-content">
        <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
            <DataControls>
                <asp:DataControlReference ControlID="GridView1" />
            </DataControls>
        </asp:DynamicDataManager>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div class="space2"></div>

               <div class="DD">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
                        HeaderText="لیست خطاها :" CssClass="DDValidator" />
                    <asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" CssClass="DDValidator" />

                    <asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
                        <ItemTemplate>
                            <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' OnPreRender="Label_PreRender" />
                            <asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" />&nbsp &nbsp &nbsp &nbsp
                        </ItemTemplate>
                    </asp:QueryableFilterRepeater>
                    <br />
                </div>

                <div class="space2"></div>

                <mani:PagingGridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
                    AllowPaging="True" AllowSorting="True" SkinID="DynamicData" PageSize="20">
                    <Columns>
                        <asp:TemplateField ControlStyle-BorderWidth="0">
                            <ItemTemplate>
                                <asp:LinkButton ID="btnDelete" runat="server" CommandName="Delete" Text="حذف" OnClientClick='return confirm("آیا نسبت به حذف این آیتم اطمینان دارید؟");' />
                                &nbsp;
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:DynamicHyperLink runat="server" Action="Edit" Text="ویرایش" />
                                &nbsp;
                                <asp:DynamicHyperLink runat="server" Text="جزییات" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>

                    <PagerStyle CssClass="DDFooter"/>        
                    <PagerTemplate>
                        <asp:GridViewPager runat="server" />
                    </PagerTemplate>
                    <EmptyDataTemplate>
                        هیچ آیتمی تعریف نشده است
                    </EmptyDataTemplate>
                </mani:PagingGridView>

                <asp:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="true" />
            
                <asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
                    <asp:DynamicFilterExpression ControlID="FilterRepeater" />
                </asp:QueryExtender>

                <br />

                <div>
                    <asp:DynamicHyperLink ID="InsertHyperLink" runat="server" Action="Insert"><img runat="server" src="~/DynamicData/Content/Images/plus.gif" alt="Insert new item" />ایجاد آیتم جدید</asp:DynamicHyperLink>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
</asp:Content>

